package com.sgb.kjwl.view.ui.activity.material;

import android.content.Context;
import android.text.TextUtils;
import android.view.View;
import android.widget.TextView;

import com.sgb.kjwl.BR;
import com.sgb.kjwl.R;
import com.sgb.kjwl.databinding.ItemHomeSearchCompanyBinding;
import com.sgb.kjwl.model.entity.HomeSearchCompanyEntity;
import com.swgk.core.recyclerview.adapter.BaseRecycleAdapter;
import com.swgk.core.recyclerview.adapter.ItemViewHolder;

import java.util.List;

public class HomeSearchCompanyAdapter extends BaseRecycleAdapter<HomeSearchCompanyEntity> {

    public HomeSearchCompanyAdapter(Context context, List<HomeSearchCompanyEntity> datas) {
        super(context, R.layout.item_home_search_company, datas);
    }

    @Override
    public void convert(ItemViewHolder holder, final HomeSearchCompanyEntity entity) {
        holder.setBinding(BR.viewModel, entity);
        ItemHomeSearchCompanyBinding itemSearchCompanyBinding = (ItemHomeSearchCompanyBinding) holder.getmBinding();
        if (entity.getAuthYear() == null) {
            holder.getView(R.id.authYear).setVisibility(View.GONE);
        } else {
            holder.getView(R.id.authYear).setVisibility(View.VISIBLE);
            ((TextView) holder.getView(R.id.authYear)).setText("入住" + entity.getAuthYear() + "年");
        }
        if(TextUtils.isEmpty(entity.getMapAddress())){
            ((TextView) holder.getView(R.id.tv_address)).setText(entity.getAreaName());
        }else{
            ((TextView) holder.getView(R.id.tv_address)).setText(entity.getMapAddress());
        }
        itemSearchCompanyBinding.imageZiying.setVisibility(entity.getSelfSupportTag() == 1 ? View.VISIBLE : View.GONE);
    }
}
